home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 February / macformat-047.iso / Shareware Plus / Developers / PlayerPRO 4.5.3 Dev.Kit / MADH Library 4.2 / Libraries & Headers / RDriver.h < prev    next >
Encoding:
Text File  |  1996-11-09  |  16.0 KB  |  467 lines  |  [TEXT/CWIE]

  1. /********************                        ***********************/
  2. //
  3. //    Player PRO 4.5x -- MAD Music Driver Definition -
  4. //
  5. //    Library Version 4.02
  6. //
  7. //    To use with MAD Library for Mac: Think, Symantec, CodeWarrior and MPW
  8. //
  9. //    Antoine ROSSET
  10. //    16 Tranchees
  11. //    1206 GENEVA
  12. //    SWITZERLAND
  13. //
  14. //    Thank you for your interest in PlayerPRO !
  15. //
  16. //    FAX:            (+41 22) 346 11 97
  17. //    PHONE:             (+41 79) 203 74 62
  18. //    Internet:         rosset@dial.eunet.ch
  19. //
  20. /********************                        ***********************/
  21.  
  22. #ifndef __RDRIVERH__
  23. #define __RDRIVERH__
  24.  
  25. #ifndef __MADH__
  26. #include "MAD.h"
  27. #endif
  28.  
  29. #ifndef __SOUND__
  30. #include <Sound.h>
  31. #endif
  32.  
  33. #ifndef __RETRACE__
  34. #include <Retrace.h>
  35. #endif
  36.  
  37. #if defined(powerc) || defined (__powerc)
  38. #pragma options align=mac68k
  39. #else
  40. #if !defined(THINK_C)
  41. #pragma options align=mac68k
  42. #endif
  43. #endif
  44.  
  45. /********************                        ***********************/
  46. /***                         Define List                            ***/
  47. /********************                        ***********************/
  48.  
  49. #define NUMBER_NOTES        96
  50. #define NOFINETUNE            8363
  51. #define MIN_VOLUME            0
  52. #define MAX_VOLUME            64
  53. #define MAXTRACK            32
  54. #define MAXINSTRU            64
  55. #define    MAXSAMPLE            25
  56. #define MAXPATTERN            200
  57. #define MAXPATTERNSIZE        900
  58. #define MAX_ARP             3
  59.  
  60. /********************                        ***********************/
  61. /***                         Error messages                         ***/
  62. /********************                        ***********************/
  63.  
  64. enum
  65. {
  66.     MADNeedMemory                     = -1,
  67.     MADReadingErr                    = -2,
  68.     MADIncompatibleFile                = -3,
  69.     MADLibraryNotInitialized        = -4,
  70.     MADParametersErr                = -5,
  71.     MADUnknowErr                    = -6,
  72.     MADSoundManagerErr                = -7,
  73.     MADOrderNotImplemented            = -8,
  74.     MADFileNotSupportedByThisPlug    = -9,
  75.     MADCannotFindPlug                = -10
  76. };
  77.  
  78. /********************                        ***********************/
  79. /***                Channel structure definition                    ***/
  80. /********************                        ***********************/
  81.  
  82. struct Channel
  83. {
  84.         long        ID;                    // Channel ID - 0 to 31
  85.  
  86.         Ptr            begPtr;                // Sample Data Ptr - Beginning of data
  87.         Ptr            maxPtr;                // Sample Data Ptr - End of data
  88.         Ptr            curPtr;                // Sample Data Ptr - Current position
  89.         long        sizePtr;            // Sample Size in bytes
  90.         
  91.         long        amp;                // Sample amplitude: 8 or 16 bits
  92.         
  93.         long        loopBeg;            // Loop Beginning
  94.         long        loopSize;            // Loop Size
  95.         
  96.         long        ins;                // Current Instrument ID
  97.         long        insOld;                // Previous Instrument ID played on this channel
  98.         long        samp;                // Current Sample ID
  99.         
  100.         long        fineTune;            // Finetune
  101.         
  102.         long        note;                // Note
  103.         long        noteOld;            // Previous note played on this channel
  104.         
  105.         long         period;                // Current period
  106.         long        periodOld;            // Previous period played on this channel
  107.         
  108.         long        vol;                // Channel vol (0 to 64)
  109.         long         cmd;                // Command
  110.         Byte        arg;                // Argument of command
  111.         Byte        volcmd;                // Volume Command
  112.         
  113.         long         arp[ MAX_ARP];        // Used for arpeggio command
  114.         long         arpindex;            // Used for arpeggio command
  115.         
  116.         long        viboffset;            // Used for vibrato command
  117.         long         vibdepth;            // Used for vibrato command
  118.         long         vibrate;            // Used for vibrato command
  119.         
  120.         long         slide;                // Used for slideUp and slideDown command
  121.         
  122.         long         pitchgoal;            // Used for portamento command
  123.         long         pitchrate;            // Used for portamento command
  124.         
  125.         long         volumerate;            // Used for slideVolume command
  126.         
  127.         long        oldArg[ 16];
  128.  
  129.         Ptr            samplePtr;            // Used internaly by MADPlaySoundData & MADPlaySndHandle
  130.         
  131.         /**/
  132.         
  133.         Boolean        KeyOn;
  134.         short        a;
  135.         short        b;
  136.         short        p;
  137.         long        volEnv;
  138.         long        volFade;
  139.         
  140.         long        lAC;
  141.         
  142.         Ptr            prevPtr;
  143.         long        lastWord, curLastWord;
  144.         long        curLevel;
  145.         
  146.         long        prevVol, curPrevVol;
  147.         
  148.         /**/
  149.         
  150.         Boolean        GEffect;
  151.         short        GPat, GReader;
  152. };
  153. typedef        struct Channel    Channel;
  154.  
  155. /********************                        ***********************/
  156. /***         Music description - used in Import/Export filter    ***/
  157. /********************                        ***********************/
  158.  
  159. struct    MADPartition
  160. {
  161.     MADSpec                    *header;                                // Music Header - See 'MAD.h'
  162.     PatData                    *partition[ MAXPATTERN];                // Patterns
  163.     sData                    *(sample[ MAXINSTRU][ MAXSAMPLE]);        // Instruments
  164. };
  165. typedef        struct MADPartition    MADPartition;
  166.  
  167. /********************                        ***********************/
  168. /***                  Driver Settings definition                    ***/
  169. /********************                        ***********************/
  170.  
  171. enum
  172. {
  173.     ASCSoundDriver = 1,
  174.     AWACSoundDriver,
  175.     MIDISoundDriver,
  176.     SoundManagerDriver,        // You should use only SoundManagerDriver for full compatibility !
  177.     QK25SoundDriver,
  178.     DigiDesignSoundDriver
  179. };
  180.  
  181. enum
  182. {
  183.     MonoOutPut = 1,
  184.     StereoOutPut,
  185.     DeluxeStereoOutPut,
  186.     PolyPhonic                // Do NOT use it ! Standard hardware doesn't support it !
  187. };
  188.  
  189. struct MADDriverSettings
  190. {
  191.     short                    numChn;                                // Active tracks from 2 to 32, automatically setup when a new music is loaded
  192.     short                    outPutBits;                            // 8 or 16 Bits
  193.     unsigned long            outPutRate;                            // Fixed number, by example : rate44khz, rate22050hz, rate22khz, rate11khz, rate11025hz
  194.     short                    outPutMode;                            // MonoOutPut, StereoOutPut or DeluxeStereoOutPut ?
  195.     short                    driverMode;                            // ASCSoundDriver, AWACSoundDriver, MIDISoundDriver or SoundManagerDriver
  196.     Boolean                    antiAliasing;                        // Use AntiAliasing filter ? true/false
  197.     Boolean                    repeatMusic;                        // If music finished, repeat it or stop.
  198.     Boolean                    sysMemory;                            // Allocate memory in Application Heap (false) or in System Heap (true)
  199.     Boolean                    Interpolation;                        // Sound Interpolation active? true/false
  200.     Boolean                    MicroDelay;                            // Micro delay active? Used only in DeluxeStereoOutPut outPutMode.
  201.     long                    MicroDelaySize;                        // Micro delay duration (in ms, max 1 sec = 1000 ms)
  202.     Boolean                    surround;                            // Surround effect active? true/false
  203.     Boolean                    Reverb;                                // Reverb effect active? true/false
  204.     long                    ReverbSize;                            // Reverb delay duration (in ms, min = 25 ms, max 1 sec = 1000 ms)
  205.     long                    ReverbStrength;                        // Reverb strength in % (0 <-> 70)
  206.     Boolean                    TickRemover;                        // Remove volume/sample/loop ticks.
  207. };
  208. typedef struct MADDriverSettings MADDriverSettings;
  209.  
  210. /********************                        ***********************/
  211. /***             Informations about Plugs: ThePlug[]                ***/
  212. /********************                        ***********************/
  213.  
  214. struct PlugInfo
  215. {
  216.     Handle        IOPlug;                                            // Plug CODE
  217.     Str63        MenuName;                                        // Plug name
  218.     Str63        AuthorString;                                    // Plug author
  219.     FSSpec        file;                                            // Location of plug file
  220.     OSType        type;                                            // OSType of file support
  221.     OSType        mode;                                            // Mode support : Import +/ Export
  222.     Boolean        hasPPCCode;                                        // Is Plug FAT?
  223. };
  224. typedef struct PlugInfo PlugInfo;
  225.  
  226.  
  227. /********************                        ***********************/
  228. /***         Global structure : PlayerPRO variables                ***/
  229. /********************                        ***********************/
  230.  
  231. struct MADDriverRec
  232. {
  233.     long                    IDType;                                // IDType = 'MADD' -- READ ONLY --
  234.  
  235.     /**********************/
  236.     /** Public variables **/
  237.     /**********************/
  238.  
  239.     MADDriverSettings        DriverSettings;                        // Driver SetUp -- READ ONLY --
  240.  
  241.     /**  Current music in memory, loaded with RLoadMusic() by example **/
  242.  
  243.     MADSpec                    *header;                            // MAD Header  -- READ ONLY --
  244.     PatData                    *partition[ MAXPATTERN];            // Patterns    -- READ ONLY --
  245.     sData                    *(sample[ MAXINSTRU][ MAXSAMPLE]);    // Instruments -- READ ONLY --
  246.     
  247.     /**  Drivers variables **/
  248.     
  249.     Channel                    chan[ MAXTRACK];                    // Current driver channels -- READ ONLY --
  250.     Boolean                    musicEnd;                            // Is music playing finished? -- READ ONLY --
  251.     short                    Tube[ MAXTRACK];                    // Used in 'Tracks View' Window - View menu 
  252.     short                    PartitionReader;                    // Current position in pattern (0...64)
  253.     short                    Pat;                                // Current ID Pattern, see 'Patterns list'
  254.     short                    PL;                                    // Current position in partition, see 'Partition list'
  255.     long                    VolExt[ MAXTRACK];                    // Volumes settings for each track, see 'Adaptators' window. from 0 to 64
  256.     long                    VolGlobal;                            // Global SOFTWARE volume (This is NOT Mac hardware volume!) from 0 to 64
  257.     short                    speed;                                // Current speed, see speed Effect
  258.     short                    finespeed;                            // Current finespeed, see speed Effect
  259.     short                    InstruTube[ MAXINSTRU];                // Used in 'Instrument View' Window - View menu
  260.     short                    VExt;                                // External music speed, see 'Adaptators' window. 80 = normal
  261.     short                    FreqExt;                            // External music pitch, see 'Adaptators' window. 80 = normal
  262.     Boolean                    Reading;                            // Reading indicator
  263.     short                    LeftRight[ MAXTRACK];                // Left/Right % for Deluxe Driver
  264.     SndChannelPtr             MusicChannelPP;                        // The SndChannelPtr to apply SndDoCommand, etc.
  265.                                                                 // ONLY available if you are using SoundManager driver
  266.  
  267.     /** Plugs Import/Export variables **/
  268.  
  269.     PlugInfo                 *ThePlug;                            // Pointers on plugs code & infos
  270.     short                    TotalPlug;                            // no of Plugs in pointer ThePlug
  271.  
  272.  
  273.     /** Private variables - Not documented **/
  274.     /* DO NOT MODIFY OR USE these variables */
  275.  
  276.     long                    MIN_PITCH, MAX_PITCH;
  277.     short                    smallcounter, trackDiv;
  278.     long                    FREQBASE;
  279.     short                    InstruActif[ MAXINSTRU];
  280.     Ptr                        SysHeapPtr, Vol, IntDataPtr, OscilloWavePtr;
  281.     Boolean                    JumpToNextPattern, endPattern, MADPlay;
  282.     long                    ASCBUFFER;
  283.     long                    BufSize;
  284.     long                    VSYNC, BufCounter, BytesToGenerate;
  285.     short                    vibrato_table[ 64];
  286.     short                    MIDIPortRefNum, gOutNodeRefNum;
  287.     SndChannelPtr             pseudoChanAWAC;
  288.     short                    InstuNoOld[ MAXTRACK];
  289.     short                    NoteOld[ MAXTRACK];
  290.     short                    VelocityOld[ MAXTRACK];
  291.     Boolean                    TrackLineReading[ MAXTRACK];
  292.     SndDoubleBufferHeader     TheHeader;
  293.     Ptr                        OverShoot;
  294.     long                    *DASCBuffer;
  295.     short                    *DASCBuffer8;
  296.     VBLTask                    VBL;
  297.     long                    VBLA5;
  298.     long                    mytab[ 12];
  299.     long                    MDelay;
  300.     long                    RDelay;
  301.     Ptr                        ReverbPtr;
  302. };
  303. typedef struct MADDriverRec MADDriverRec;
  304.  
  305. extern    MADDriverRec        *MADDriver;
  306.  
  307. /********************                        ***********************/
  308. /***                        EFFECTS ID                            ***/
  309. /********************                        ***********************/
  310.  
  311. enum {
  312.         arpeggioE         = 0,    //    0x00
  313.         downslideE         = 1,    //    0x01
  314.         upslideE         = 2,    //    0x02
  315.         portamentoE     = 3,    //    0x03
  316.         vibratoE         = 4,    //    0x04
  317.         portaslideE     = 5,    //    0x05
  318.         vibratoslideE    = 6,    //    0x06
  319.         nothingE         = 7,    //    0x07
  320.         offsetE         = 9,    //    0x08
  321.         slidevolE         = 10,    //    0x0A
  322.         fastskipE         = 11,    //    0x0B
  323.         volumeE         = 12,    //    0x0C
  324.         skipE             = 13,    //    0x0D
  325.         extendedE         = 14,    //    0x0E
  326.         speedE             = 15    //    0x0F
  327.     };
  328.  
  329. /********************                        ***********************/
  330. /***                        FUNCTIONS                            ***/
  331. /********************                        ***********************/
  332.  
  333.  
  334. #ifdef __cplusplus
  335. extern "C" {
  336. #endif
  337.  
  338. OSErr    MADInitLibrary( Str255 PlugsFolderName, Boolean SysMemory);    // Library initialisation, you have to CALL this function if you want to use other functions & variables
  339. OSErr    MADDisposeLibrary( void);                                    // Close Library, close music, close driver, free all memory
  340.  
  341. void    MADGetBestDriver( MADDriverSettings    *DriverInitParam);        // Found and identify the current Mac sound hardware and fill DriverInitParam
  342. OSErr    MADCreateDriver( MADDriverSettings    *DriverInitParam);        // Music Driver initialization and memory allocation
  343. OSErr    MADDisposeDriver();                                            // Dispose the music driver, use it after RInitMusic()
  344.  
  345. OSErr    MADPlay( void);                                                // Play the current music
  346. OSErr    MADStop( void);                                                // Stop the current music
  347. OSErr    MADReset( void);                                            // Reset the current music at the start position
  348. OSErr    MADGetMusicStatus( long *fullTime, long *curTime);            // Get informations about music position and duration
  349.  
  350. OSErr    MADSetHardwareVolume( long);                                // 0...64, Mac HARDWARE volume, see MADDriver->VolGlobal for SOFTWARE volume
  351. long    MADGetHardwareVolume();                                        // Return HARDWARE volume, see MADDriver->VolGlobal for SOFTWARE volume
  352.  
  353. OSErr    MADLoadMusicFile( Str255 fName);                            // Load a MAD File in the current directory
  354. OSErr    MADLoadMusicFSpFile( FSSpec *theSpec);                        // Same as above but with a FSSpec pointer
  355. OSErr    MADLoadMusicRsrc( OSType IDName, short IDNo);                // Load a MAD Rsrc into memory
  356. OSErr    MADLoadMusicPtr( Ptr myPtr);                                // Load a MAD Ptr into memory, you can DisposPtr your Ptr after this call
  357. OSErr    MADLoadMusicPartition( MADPartition *aPartition);            // Load a MAD partition into memory
  358. OSErr    MADImportMusicFile( OSType plugType, Str255 fName);            // Import a non-MAD music file with plugs
  359. OSErr    MADImportMusicFSpFile( OSType plugType, FSSpec *theSpec);    // Same as above but with a FSSpec pointer
  360. OSErr    MADMusicIdentify( OSType *type, Str255 fName);                // Identify what kind of music format is fName file.
  361. OSErr    MADMusicIdentifyFSp( OSType *type, FSSpec *theSpec);        // Same as above but with a FSSpec pointer
  362. Boolean    MADPlugAvailable( OSType type);                                // Is plug 'type' available?
  363.  
  364. OSErr    MADDisposeMusic(void);                                        // Dispose the current music, use it after RLoadMusic(), RLoadMusicRsrc(), RInstallMADF()
  365.  
  366. void    MADChangeTracks( short);                                    // Change current tracks number of the music driver
  367. void    MADCleanDriver( MADDriverRec *intDriver);                    // Clean the driver : stop playing sounds
  368. Cmd*    GetMADCommand(    short        position,                        // Extract a Command from a PatData structure
  369.                         short        channel,
  370.                         PatData*    aPatData);
  371.  
  372. OSErr    MADPlaySndHandle(     Handle sound,                            // Handle to a 'snd ' handle, by ex: GetResource('snd ', 128);
  373.                             long chan,                                // channel ID on which to play sound
  374.                             long note);                                // note: 0 to NUMBER_NOTES or 0xFF: play sound at his normal sampleRate Khz
  375.  
  376. OSErr    MADPlaySoundData(    Ptr                soundPtr,                // Sound Pointer to data
  377.                             long            size,                    // Sound size in bytes
  378.                             long            channel,                // channel ID on which to play sound
  379.                             long            note,                    // note: 0 to NUMBER_NOTES or 0xFF: play sound at 22 Khz
  380.                             long            amplitude,                // 8 or 16 bits
  381.                             long            loopBeg,                // loop beginning
  382.                             long            loopSize,                // loop size in bytes
  383.                             unsigned long    rate);                    // sample rate of the sound data, by ex: rate22khz
  384.  
  385. OSErr    MADPlaySoundDataSYNC(Ptr            soundPtr,                // Sound Pointer to data
  386.                             long            size,                    // Sound size in bytes
  387.                             long            channel,                // channel ID on which to play sound
  388.                             long            note,                    // note: 0 to NUMBER_NOTES or 0xFF: play sound at 22 Khz
  389.                             long            amplitude,                // 8 or 16 bits
  390.                             long            loopBeg,                // loop beginning
  391.                             long            loopSize,                // loop size in bytes
  392.                             unsigned long    rate);                    // sample rate of the sound data, by ex: rate22khz
  393.  
  394. #ifdef __cplusplus
  395. }
  396. #endif
  397.  
  398. /******************************************************************/
  399. //******************* MUSICS IMPORT/EXPORT PLUGS  *****************/
  400. //
  401. //    Protocol Version 2.1
  402. //
  403. //    To use with PlayerPRO for Think C & CodeWarrior
  404. //
  405. //    Your main function have to be in this form:
  406. //    OSErr main(     OSType order,
  407. //                    FSSpec *AlienFileFSSpec,
  408. //                    MADPartition *MadFile,
  409. //                    PPInfoRec *info,
  410. //                    MADDriverSettings *DriverParam);
  411. //
  412. //    Actual plug have to support these orders:
  413. //
  414. //    order: 'TEST':    check the AlienFile to see if your Plug really supports it.
  415. //    order: 'IMPT':    convert the AlienFile into a MADPartition. You have to allocate MADPartition.
  416. //    order: 'INFO':    Fill PPInfoRec structure.
  417. //    order: 'EXPT':    Convert the MADPartition into AlienFile. You have to create the AlienFile.
  418. //                    Don't delete the MADPartition Structure after conversion !!
  419. //
  420. //    An IMPORT plug have to support these orders: 'TEST', 'IMPT', 'INFO'
  421. //    An EXPORT plug have to support these orders: 'EXPT'
  422. //     An IMPORT/EXPORT plug have to support these orders: 'TEST', 'IMPT', 'INFO', 'EXPT'
  423. //
  424. //    About Resources:
  425. //
  426. //    Your Plug should have: Creator: 'SNPL', Type: 'IMPL'
  427. //
  428. //    Your Plug have to have these resources:
  429. //
  430. //    - One segment CODE 1000 with 68k Code
  431. //    - One segment PPCC 1000 with PPC Code (OPTIONAL: if PlayerPRO in PPC cannot find it, it will use the CODE 1000 resource)
  432. //    - One STR# resource :
  433. //
  434. //        1 string: which kind of files your plug support (OSType value!!! 4 char) By example: 'STrk', '669 ', etc...
  435. //        2 string: what does your Plug: EXPL : only Export files, IMPL : only Import Files, EXIM : import AND export.
  436. //        3 string: string that will be used in Import and Export menu of PlayerPRO
  437. //        4 string: Copyright string of this plug.
  438. //
  439. /********************                        ***********************/
  440.  
  441. struct PPInfoRec
  442. {
  443.     Str63        internalFileName;
  444.     Str63        formatDescription;
  445.     
  446.     long        totalPatterns;
  447.     long        partitionLength;
  448.     
  449.     short        totalTracks;
  450.     short        totalInstruments;
  451.     
  452.     OSType        signature;
  453.     
  454.     long        fileSize;
  455.     
  456. };
  457. typedef struct PPInfoRec PPInfoRec;
  458.  
  459.  
  460. #if defined(powerc) || defined (__powerc)
  461. #pragma options align=reset
  462. #else
  463. #if !defined(THINK_C)
  464. #pragma options align=reset
  465. #endif
  466. #endif
  467. #endif